<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let aa = new Promise(function (reslove, reject) {
            setTimeout(function () {
                reject(1);
            }, 5000);
        });
        let bb = new Promise(function (reslove, reject) {
            setTimeout(function () {
                reslove(2);
            }, 0);
        });
        function myAllSettled(list) {
            let resultArr = [];
            let num = 0;
            return new Promise((reslove) => {
                list.forEach((val, index) => {
                    val.then(
                        (res) => {
                            let obj = {
                                status: 'fulfilled',
                                value: res,
                            };
                            num++;
                            resultArr[index] = obj;
                            if (num == list.length) {
                                reslove(resultArr);
                            }
                        },
                        (err) => {
                            let obj = {
                                status: 'rejected',
                                reason: err,
                            };
                            num++;
                            resultArr[index] = obj;
                            if (num == list.length) {
                                reslove(resultArr);
                            }
                        }
                    );
                });
            });
        }
        myAllSettled([aa, bb]).then((res) => {
            console.log(res);
        });
    </script>
</body>

</html>